import React,{ useEffect } from 'react'
import { useSelector } from 'react-redux'

export default function CounterShow() {
  // 使用 useSelector 获取 Redux store 中的 count 值
  const counter = useSelector(state => state.counter);
  const user = useSelector(state => state.user);

  useEffect(() => {
    console.log("CounterShow component rendered with count:", counter.count);
  }, [counter.count]);

  return (
    <div>
      <h2>Count: {counter.count}</h2>
      <h2>User Name: {user.name}</h2>
    </div>
  );
}